<?php
namespace app\admin\controller;
use app\common\BaseController;
use app\admin\model\Role as RoleModel;
class Role extends BaseController
{

    public function index(RoleModel $rolemodel){

    	
    	
    	

        return view('index');
    }
    public function getInfo(RoleModel $rolemodel){
    	$page = input('page');
    	$limit = input('limit');
    	$role = $rolemodel->Aselect($page,$limit);
    	return $role;
    }
    public function addRole(RoleModel $rolemodel){
       if(request()->isAjax() && request()->isPost()){
       		if($rolemodel->save(object_to_array(input()))){
               return true;
            }else{  
               return false;
            }
       }
        return view('add');
    }

    public function edit($id,RoleModel $rolemodel){
    	
    	if(request()->isAjax() && request()->isPost()){
       		$rolemodel->save(input(),['id'=>input('id')]);
       		
       }
    	$role = $rolemodel->where('id',$id)->find();

    	return view('edit',['role'=>$role]);
    }
}

